package com.gzck.gzck_verson2.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzck.gzck_verson2.pojo.GProjectType;
import com.gzck.gzck_verson2.pojo.page.MyPage;
import com.gzck.gzck_verson2.service.IGProjectTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 工程类型 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-06
 */
@RestController
@RequestMapping("/g-project-type")
@CrossOrigin(origins = "*")
public class GProjectTypeController {

    @Autowired
    private IGProjectTypeService gProjectTypeService;

    // 添加工程类型
    @PostMapping("/add")
    public boolean addProjectType(@RequestBody GProjectType projectType) {
        return gProjectTypeService.save(projectType);
    }

    // 删除工程类型
    @DeleteMapping("/delete/{id}")
    public boolean deleteProjectType(@PathVariable Long id) {
        return gProjectTypeService.removeById(id);
    }

    // 更新工程类型信息
    @PutMapping("/update")
    public boolean updateProjectType(@RequestBody GProjectType projectType) {
        return gProjectTypeService.updateById(projectType);
    }

    // 查询单个工程类型信息
    @GetMapping("/{id}")
    public GProjectType getProjectType(@PathVariable Long id) {
        return gProjectTypeService.getById(id);
    }

    // 查询所有工程类型信息
    @GetMapping("/all")
    public List<GProjectType> getAllProjectTypes() {
        return gProjectTypeService.list();
    }


}
